package com.longge;

import java.util.Arrays;

public class HIndex {

    public int hIndex(int[] citations) {

        Arrays.sort(citations);
        int ans = 0;
        for (int i = 0; i < citations.length; i++) {
            int h = citations.length - i;
            ans = Math.max(Math.min(h,citations[i]), ans);

        }
        return ans;

    }

}
